using NExt.Core.Model.Enum;
using NExt.Demo.Application.Entity3.Model;
using NExt.form;
using NExt.UI.Edit.Base;

namespace NExt.Demo.Application.Entity3
{
    public class Edit : EditPresenterBase
    {
        public TextField txtName;
        public TextField txtLastname;
        public NumberField txtAge;
        public TextField txtHomeAddress;

        protected override void FormBuildComponents()
        {
            base.FormBuildComponents();
            txtName = new TextField();
            txtLastname = new TextField();
            txtAge = new NumberField();
            txtHomeAddress = new TextField();
        }

        protected override void FormInitializeComponents()
        {
            base.FormInitializeComponents();
            txtName.dataMember = Bind.To<Customer>(c => c.Person.Name);
            txtName.fieldLabel = "Name";

            txtLastname.dataMember = Bind.To<Customer>(c => c.Lastname);
            txtLastname.fieldLabel = "Lastname";

            txtAge.dataMember = Bind.To<Customer>(c => c.Person.Age);
            txtAge.fieldLabel = "Age";

            txtHomeAddress.dataMember = Bind.To<Customer>(c => c.Person.Address.Home);
            txtHomeAddress.fieldLabel = "Home Address";

            defaults = BodyStyle.DEFAULT_PADDING;
            formPanel.items.Add(txtName);
            formPanel.items.Add(txtLastname);
            formPanel.items.Add(txtAge);
            formPanel.items.Add(txtHomeAddress);
        }
    }
}